package com.alibaba.aliper.agent.basher;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;

public class GetWords {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		Vector<Integer> argss = new Vector<Integer>();
		for(String arg : args){
			try{
				int value = Integer.parseInt(arg);
				argss.add(value);
			} catch (Exception e) {
				System.err.println(e);
			}
		}
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while((line = reader.readLine()) != null){
			for(int index : argss){
				String word = getWord(line,index);
				System.out.print(word+" ");
			}
			System.out.println();
		}
	}

	private static String getWord(String line, int index) {
		if(index < 0)
			return "";
		line = line.replaceAll("\\s+", "&&");
		if(line.startsWith("&&")){
			line = line.substring(2);
		}
		if(!line.endsWith("&&")){
			line+="&&";
		}
		int start = 0;
		int end = -2;
		for(int i = 0; i < index ; ++i){
			start = end + 2;
			end = line.indexOf("&&",start);
			if(end < 0)
				return "";
		}
		return line.substring(start,end);
	}

}
